package edu.uestc.gene.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Carl
 * 
 *         2013-10-28
 */
public class Drug implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name;
	private List<AdverseDrugReaction> drug_adrs;
	private List<Gene> drug_genes;

	/**
	 * @param name
	 */
	public Drug(String name) {
		super();
		this.name = name;
		drug_adrs = new ArrayList<AdverseDrugReaction>();
		drug_genes = new ArrayList<Gene>();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Drug)) {
			return false;
		}
		Drug drug = (Drug) obj;
		return drug.getName().equals(name);
	}

	public void removeGene(Gene gene) {
		if (drug_genes.indexOf(gene) != -1) {
			drug_genes.remove(gene);
		}
	}

	public void removeGenes(List<Gene> genes) {
		for (int i = 0; i < genes.size(); i++) {
			removeGene(genes.get(i));
		}
	}

	public void addGene(Gene gene) {
		if (drug_genes.indexOf(gene) == -1)
			drug_genes.add(gene);
	}

	public void addGene(String gene) {
		addGene(new Gene(gene));
	}

	public void addADR(AdverseDrugReaction adr) {
		drug_adrs.add(adr);
	}

	public void addADR(String adr) {
		addADR(new AdverseDrugReaction(adr));
	}

	public List<AdverseDrugReaction> getDrug_adrs() {
		return drug_adrs;
	}

	public void setDrug_adrs(List<AdverseDrugReaction> drug_adrs) {
		this.drug_adrs = drug_adrs;
	}

	public List<Gene> getDrug_genes() {
		return drug_genes;
	}

	public void setDrug_genes(List<Gene> drug_genes) {
		this.drug_genes = drug_genes;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
